<?php

require_once("./include/include.php");


$sql_name = $_SESSION["username"];

$sql = "SELECT COUNT(uid) as c FROM message";

$res = mysql_query($sql);
$r = mysql_num_rows($res);
if ($r) {
  $row = mysql_fetch_assoc($res);
}
$count = $row['c'];


$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$pagesize = 5;
$pagecount = ceil($count / $pagesize);
$pagestart = ($page - 1) * $pagesize;

$sql = "SELECT * FROM message LEFT JOIN user ON  message.uid = user.uid ORDER BY message.mid DESC LIMIT $pagestart, $pagesize";
$result = mysql_query($sql);
$useArr = array();
while ($row = mysql_fetch_assoc($result)) {
  $useArr[] = $row;
}

$page_link = page_links($pagecount, $page);
//    print_r($useArr);

?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>客户留言</title>
  <link rel="stylesheet" href="css/user_msg.css">
</head>
<body>
<div class="container">
    <include file="./Home/Tpl/public/header.html" />
  <div class="banner">
	<img src="images/cases_banner.gif" alt="">
  </div>
  <div class="main">
	<div class="main_title">
	  <a href="">首页</a>
	  <span>></span>
	  <a href="">用户中心</a>
	  <span>></span>
	  <a href="">客户留言</a>
	</div>
	<div class="main_top">
	  <div class="con_left fl">
		<p class="username">
		  <span><?php echo $_SESSION['username']; ?></span>
		</p>

		<p>
		  <a href="">基本信息<span>></span></a>
		</p>

		<p>
		  <a href="">账号设置<span>></span></a>
		</p>

		<p>
		  <a href="">客户留言<span>></span></a>
		</p>
	  </div>
	  <div class="con_right fr">
		<div class="user_info">
		  <span>客户留言</span>
		</div>
		<div class="con_right_info">
		  <?php foreach ($useArr as $value) { ?>
			<dl>
			  <dt><?php echo date("Y-m-d H:i", $value["addtime"]); ?>
				<span>用户名 : <?php echo $value["username"]; ?></span></dt>
			  <dd><?php echo $value["content"]; ?></dd>
			  <dd class="et">邮箱：<?php echo $value["Email"]; ?>    <span>电话：<?php echo $value["mobile"]; ?></span></dd>
			</dl>
		  <?php } ?>
		</div>
		<div class="main_next">
		  <div class="page_list">
			<?php echo $page_link; ?>
		  </div>
		</div>
	  </div>
	</div>
  </div>
    <include file="./Home/Tpl/public/footer.html" />
</div>
</body>
</html>